home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************
- "AppleEvents.c"
-
- by John A. Love, III [ Washington Apple Pi Users' Group]
-
- using Symantec's "THINK C", v 5.00
- *********************************************************/
-
-
- #ifndef __APPLEEVENTS__
- #include <AppleEvents.h>
- #endif
-
- #ifndef __EPPC__
- #include <EPPC.h>
- #endif
-
- #ifndef __GESTALTEQU__
- #include <GestaltEqu.h>
- #endif
-
- #include "protos"
-
- #include "globals.h"
- #include "extern.h"
-
-
-
-
- short _GestaltTrap = 0xA1AD;
- long myFeature;
-
-
- Boolean AppleEventsActive (void) {
- /* Do we have a machine on which the Apple Events Manager exists ??? */
-
- if (TrapAvailable(_GestaltTrap)) {
- if (Gestalt(gestaltAppleEventsAttr, &myFeature) == noErr) {
- if (BitTst(&myFeature, 31 - gestaltAppleEventsPresent)) return(true);
- else return(false);
- }
- else return(false);
- }
- else return(false);
-
- } /* AppleEventsActive */
-
-
-
- Boolean PPCToolboxActive (void) {
- /* Do we have a machine on which the PPCToolbox exists ??? */
-
- Boolean result;
-
-
- result = false; /* Be pessimistic ... see if I care !! */
- ;
- if (TrapAvailable(_GestaltTrap)) {
- if (Gestalt(gestaltPPCToolboxAttr, &myFeature) == noErr) {
- if (BitTst(&myFeature, 31 - gestaltPPCToolboxPresent)) result = true;
- }
- }
-
- return(result);
-
- } /* PPCToolboxActive */
-
-
-
- OSErr InitAppleEvents (void) {
-
-
-
- } /* InitAppleEvents */
-
-
-
- OSErr InitPPCToolbox (void) {
-
- OSErr err;
-
-
- gHasPPCToolbox = PPCToolboxActive();
-
- if (gHasPPCToolbox) {
-
- if ((myFeature & gestaltPPCSupportsRealTime) == 0) {
- err = PPCInit();
- if (err == noErr) err = Gestalt(gestaltPPCToolboxAttr, &myFeature);
- }
- else /* does NOT need initialization */ err = noErr;
- }
- else err = noPPCToolboxErr;
-
- return (err);
-
- } /* InitPPCToolbox */
-
-
-
- OSErr AcceptHLEvent (void) {
-
- OSErr err;
- Ptr myBuff;
- unsigned long myLen;
- TargetID theClient;
- unsigned long clientRefcon;
-
-
- myLen = 0; /* Start with zero to allow _AcceptHighLevelEvent */
- myBuff = nil; /* to determine the size. */
-
- err = AcceptHighLevelEvent(&theClient, &clientRefcon, myBuff, &myLen);
- ;
- if (err == bufferIsSmall) {
- myBuff = NewClearPtr(myLen);
- err = AcceptHighLevelEvent(&theClient, &clientRefcon, myBuff, &myLen);
- }
-
- return (err);
-
- } /* AcceptHLEvent */
-
-
-
- OSErr MissedAnyParameters (EventRecord *event, AppleEvent *theAEEvent) {
-
- OSErr err;
- DescType ignoredActualType;
- AEKeyword missedKeyword;
- Size ignoredActualSize;
-
-
- err = AEGetAttributePtr(theAEEvent,
- keyMissedKeywordAttr,
- typeKeyword,
- &ignoredActualType,
- (Ptr)(&missedKeyword),
- sizeof(missedKeyword),
- &ignoredActualSize);
-
- if (err == noErr) { /* We found some unused parameters. */
- event->message = *(long *) (&ignoredActualType);
- event->where = *(Point *) (&missedKeyword);
- err = errAEEventNotHandled;
- }
- else if (err == errAEDescNotFound) err = noErr; /* No more. */
-
- return (err);
-
- } /* MissedAnyParameters */
-
-
-
-
- /* { end file "AppleEvents.c" } */
-